import java.util.Arrays;

public class UtilTab {
    public static double somme(double[]array){
        double sum=0;
        for (double i:array)
            sum+=i;
        return sum;
    }
    public static void incre(double d,double[]array){
        for (int i=0;i<array.length;++i)
            array[i]+=d;
    }
    public static double[]genere(int n,double[]array){
        double[]tmp=new double[Math.min(n,array.length)];
        for (int i=0,j=0;i<array.length&&j<n;++i)
            if(array[i]%2==1)tmp[j++]=array[i];

        return tmp;
    }
    public static double[]somme2(double[]a1,double[]a2){
        double[]a3=new double[Math.max(a1.length,a2.length)];
        int i=0,j=0;
        for (;i<a1.length&&j<a2.length;++i,++j)
            a3[i]=a1[i]+a2[j];

        for (;i<a1.length;++i)
            a3[i]=a1[i];

        for (;j<a2.length;++j)
            a3[j]=a2[j];

        return a3;
    }
    public static void affiche(double[]array){
        System.out.println(Arrays.toString(array));
    }

    public static void main(String[] args) {
        double a[]={1,4,2,3,5,7,8};
        System.out.println(somme(a));
        incre(1,a);
        affiche(a);
        affiche(genere(100,a));
        affiche(somme2(a,a));
    }
}